package com.qidian.mes.md.service.impl;

import com.qidian.mes.md.mapper.MdCustomerMapper;
import com.qidian.mes.md.service.CustomerService;
import com.qidian.mes.pojo.MdCustomer;
import com.qidian.mes.util.pojo.QdResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: CoolPro
 * @Description:
 * @Time: 2024-04-09 20:43
 **/
@Service
public class CustomerServiceImpl implements CustomerService {
    @Autowired
    MdCustomerMapper mdCustomerMapper;

    @Override
    public QdResult getCustomers(String keyWord, Integer page, Integer limit) {
        return QdResult.success(mdCustomerMapper.getCustomers(keyWord, (page-1)*limit, limit));
    }

    @Override
    public QdResult getCustomerById(Long id) {
        return QdResult.success(mdCustomerMapper.getCustomerById(id));
    }

    @Override
    public QdResult insertCustomer(MdCustomer customer) {
        mdCustomerMapper.insertCustomer(customer);
        return QdResult.success();
    }

    @Override
    public QdResult updateCustomer(MdCustomer customer) {
        mdCustomerMapper.updateCustomer(customer);
        return QdResult.success();

    }

    //用作删除用户和数据恢复
    @Override
    public QdResult updateUserStatus(Long id, Integer status) {
        mdCustomerMapper.updateUserStatus(id,status);
        return QdResult.success();
    }

    @Override
    public QdResult getCount() {
        return QdResult.success(mdCustomerMapper.getCount());
    }


}
